<?php

require_once 'classes/LightPressPlugin.php';

class ArchivesLatest extends LightPressPlugin {

    var $default_context = LP_CONTEXT_ALL;
    var $active = true;
    var $hooks = array('post_render');

    var $description = 'Simply generates a template tag to link to the latest archive page.  That\'s it.';
    var $constructor_args = array();
    
    var $_frontend;

    function ArchivesLatest(&$frontend, $args, $dummy_run=false) {
		$this->LightPressPlugin($frontend, $args, $dummy_run);
    }
    
    function hide() {
        $tpl->setVar('PLUGIN_ARCHIVESLATEST', '');
    }

    function run($hook, &$templates) {
		if (!$this->active)
			return;
        $archives =& $this->_frontend->getArchives();
        
        $tpl =& $this->_frontend->tpl;
        foreach($archives as $a) {
            // grab data for first entry only
            $tpl->setFile('plugin_archiveslatest', 'plugins/archiveslatest.xml');
            foreach($a as $k=>$v)
                $tpl->setVar('plugin_archiveslatest_' . $k, $v);
            $tpl->parse('PLUGIN_ARCHIVESLATEST', 'plugin_archiveslatest');
            break;
        }
        return;
	}
}

?>